<template>
	<view>
		<goods-list @goodsItemClick="goGoodsDetail" :hotgoods="hotgoods"></goods-list>
		<!-- <view class="isOver" v-if="flag">我是有底线的</view> -->
	</view>
</template>

<script>
	/* 把全局组件传过来 */
	import goodsList from '../../components/goods-list/goods-list.vue'
	export default {
		data() {
			return {
				pageindex:1,
				hotgoods:[],
				falg:false
			}
		},
		onLoad() {
			this.getGoodsList()
		},
		components:{"goods-list":goodsList},
		methods: {
		//获取商品列表数据 
		async getGoodsList(){
			const res =await this.$myRuquest({
					url:'/hotgoods?pageindex='+this.pageindex
				})
				/* this.hotgoods = res.data */
				this.hotgoods=[...this.hotgoods,...res.data]
			},
			
		//商品详情页点击事件
			goGoodsDetail(id){
				uni.navigateTo({
					url:'/pages/goods-detail/goods-detail?id='+id
				})
			}
			
			
		},
		onReachBottom() {
			/* if(this.hotgoods.length<this.pageindex*5)
			return this.falg=true
			console.log('触底了')
			this.pageindex++
			this.getGoodsList() */
		}
		
		
	}
</script>

<style>
.goods_list{
	background-color: #eee;
}
</style>
